package com.jy.modules.cims.fundsbalance.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.jy.modules.cims.data.dto.fundsbalance.FundsRepayStreamDTO;
import com.jy.modules.cims.fundsbalance.service.FundsrepayStreamService;
import com.jy.platform.core.message.DataMsg;
import com.jy.platform.core.message.PageParameter;
import com.jy.platform.core.message.PageUtil;
import com.jy.platform.core.message.QueryReqBean;
import com.jy.platform.restservice.exception.AbaboonException;
import com.jy.platform.restservice.web.base.BaseController;

/**
 * @classname: TCMmFundsrepayStreamController
 * @description: 定义  t_c_mm_fundsrepay_stream 控制层
 * @author:  jieyue
 */
@Controller
@Scope("prototype")
@RequestMapping("/tCMmFundsrepayStream")
public class TCMmFundsrepayStreamController extends BaseController{
    private static final Logger logger =  LoggerFactory.getLogger(TCMmFundsrepayStreamController.class);

    @Autowired
    @Qualifier("com.jy.modules.cims.fundsbalance.service.FundsrepayStreamService")
    private FundsrepayStreamService service;
    
    
    
    /**
     * 通过 Controller 请求 跳转 进入至相关 页面
     */
    @RequestMapping(value = "/prepareExecute/{operate}")
    public ModelAndView execute(@PathVariable("operate") String operate) throws AbaboonException {
        ModelAndView model = new ModelAndView();
        if("toQueryPage".equals(operate)){//跳转至 查询页面
        	model.setViewName("cims/funds/repaystream/queryTCMmFundsrepayStream");
        }
        
        return model;
    }
    
    /**
     * @author jieyue
     * @description:查询分页列表
     * @date 2017-04-24 17:05:32
     * @param request
     * @param dto
     * @param dataMsg
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/queryListTCMmFundsrepayStream")
    @ResponseBody
    public DataMsg queryListTCMmFundsrepayStream(HttpServletRequest request, FundsRepayStreamDTO dto, @ModelAttribute DataMsg dataMsg) throws Exception {
        
    	Map<String, Object> searchParams = new HashMap<String, Object>();
    	searchParams.put("dto", dto);
        QueryReqBean params = new QueryReqBean();
        params.setSearchParams(searchParams);
    	PageParameter pageInfo = PageUtil.toPageParameter(dataMsg);
		params.setPageParameter(pageInfo);
        List<FundsRepayStreamDTO> list = service.searchFundsrepayStreamByPaging(params.getSearchParams());
        dataMsg.setData(list);
        dataMsg.setTotalRows(pageInfo.getTotalCount());
        return dataMsg;
    }
    

    
}
